function getSignin(obj) {
	 var src = 'http://vip.niukewang.com/user/register/?ename=' + $(obj).attr('name');
        $('#niukelogin').modal('show');
		
       $('#niukelogin iframe').attr('src', src).ready();
    }
function chkweixin(){
        return (function(){return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1})();
    }
	 function loadContent(tid){
        $("#bookbody").html("<tr><td colspan=\"8\">数据加载中...</td></tr>");
        var isWx=chkweixin();
        $.getJSON("/static/niu/json/json.php?t="+tid,function(r){
            var result='';
            $.each(r,function(i,v){
				// console.log(v)
                result+=" <tr> <td><div class=\"tl softlist_name\"><a href=http://vip.niukewang.com/user/register/?ename="+v.en+">"+v.ttitle+"</a></div></td><td class=\"hidden-xs\"><div class=\"tl softlist_ti\">"+v.tiliang+"道</div></td><td class=\"visible-xs visible-sm softlist_m\"><a onclick=\"OpenWeixinTip('http://www.niukebaodian.net/niuke.apk')\" target=\"_blank\">APP下载</a><td class=\"hidden-xs hidden-sm softlist_m\"><a  href=\"javascript:;\" onclick=\"sjb('wszg',event)\" target=\"_blank\">APP下载</a>"
                if(isWx){
                   
					
					result+="<td class=\"softlist_price\"><a href=\"javascript:void(0);\" name="+v.en+" target=_blank data-toggle=\"modal\" title="+v.ttitle+" data-target=\"#niukelogin\" aria-labelledby=\"myModalLabel\">题库</a></td><td class=\"hidden-xs softlist_price\">";
					
					if(v.ke>0){
					result+="<a href=\"javascript:void(0);\" name="+v.en+" target=_blank data-toggle=\"modal\" title="+v.ttitle+" data-target=\"#niukelogin\" aria-labelledby=\"myModalLabel\">课程</a>";
					}
					result+="</td><td class=\"hidden-xs softlist_info\">";
					if(v.wuyou>0){
					result+="<a href=\"javascript:void(0);\" name="+v.en+" target=_blank data-toggle=\"modal\" title="+v.ttitle+" data-target=\"#niukelogin\" aria-labelledby=\"myModalLabel\">提分班</a></td>";
					}
					result+="<td class=\"softlist_price\">";
					if(v.mianshen>0){
					result+="<a href=\"javascript:void(0);\" name="+v.en+" target=_blank data-toggle=\"modal\" title="+v.ttitle+" data-target=\"#niukelogin\" aria-labelledby=\"myModalLabel\">面审</a>";
					}
					result+="</td><td class=\"softlist_price buybtn\"><a  href=\"javascript:;\" onclick=\"OpenWeixinTip('http://vip.niukewang.com/alipay/alipay.html?name="+v.en+"')\"></a></td></tr>"
                }
				
				else{
                    
                    
					
					result+="<td class=\"softlist_price\"><span style=\"color:#06F;cursor:pointer;\" name="+v.en+" target=_blank title="+v.ttitle+" onclick=\"getSignin(this);\">题库</span></td><td class=\"hidden-xs softlist_price\">";
					
					if(v.ke>0){
					result+="<span style=\"color:#06F;cursor:pointer;\" name="+v.en+" target=_blank title="+v.ttitle+" onclick=\"getSignin(this);\">课程</span>";
					}
					result+="</td><td class=\"hidden-xs softlist_info\">";
					if(v.wuyou>0){
					result+="<span style=\"color:#06F;cursor:pointer;\" name="+v.en+" target=_blank title="+v.ttitle+" onclick=\"getSignin(this);\">提分班</span></td>";
					}
					result+="<td class=\"softlist_price\">";
					if(v.mianshen>0){
					result+="<span style=\"color:#06F;cursor:pointer;\" name="+v.en+" target=_blank title="+v.ttitle+" onclick=\"getSignin(this);\">面审</span>";
					}
					result+="</td><td class=\"softlist_price  buybtn\"><a href=\"http://vip.niukewang.com/alipay/alipay.html?name="+v.en+"\"></a></td></tr>"
                }

            });
            $("#bookbody").html(result);
        });
    }
	function OpenWeixinTip(url){
        if(chkweixin()){
            $("#weixin-tip").show();
            return;
        }
        window.location.href=url;
    }
    $(function(){


        $("#booktitle a").click(function(){
            var tid=$(this).attr('atid');
            loadContent(tid);
        });
        $("#booktitle a:first").click();
    })
    $('.ceng').click(function(){   
   $('#niukelogin').modal('hide');
   })
